import config from '@/config';
import RequestBase from '@/utils/request.js';

const request = new RequestBase(config.equipment);
const safetyReq = new RequestBase(config.safetyUrl);

export function getDeviceType(data) {
	return request.get('/dfm/deviceType/list', data);
}

export function getDeviceName(data) {
	return request.get('/dfm/deviceLedger/list', data);
}

// 报备
export function addItem(data) {
	return request.post('/mobile/dfm/deviceExamine/add', data);
}

/**
 * 查询待办
 */
export function getItem(data) {
	return request.get('/mobile/dfm/deviceExamine/myTodoList', data);
}

/**
 * 查询经办
 */
export function getHandle(data) {
	return request.get('/mobile/dfm/deviceExamine/myHandleList', data);
}

/**
 * 查询可回退节点
 */
export function getNode(taskId) {
	return request.get('/mobile/dfm/deviceExamine/getRollbackNodes/' + taskId);
}

/**
 * 检修详情
 */
export function queryInfo(id) {
	return request.get('/mobile/dfm/deviceExamine/' + id);
}

/**
 * 申请
 */
export function apply(data) {
	return request.put('/mobile/dfm/deviceExamine/apply', data);
}

/**
 * 审核
 */
export function approve(data) {
	return request.put('/mobile/dfm/deviceExamine/process', data);
}

/**
 * 交付手续
 */
export function deliver(data) {
	return request.put('/mobile/dfm/deviceExamine/deliver', data);
}

/**
 * 教育
 */
export function train(data) {
	return request.put('/mobile/dfm/deviceExamine/train', data);
}

//教育验收事项
export function getTrain(examineId) {
	return request.get(
		'/mobile/dfm/deviceExamine/getExamineTrainList/' + examineId
	);
}

/**
 * 教育验收
 */
export function trainReceive(data) {
	return request.put('/mobile/dfm/deviceExamine/train-receive', data);
}

//检修步骤
export function getStep(examineId) {
	return request.get(
		'/mobile/dfm/deviceExamine/getExamineApplyList/' + examineId
	);
}

/**
 * 措施
 */
export function cure(data) {
	return request.put('/mobile/dfm/deviceExamine/cure', data);
}

/**
 * 保护用品
 */
export function item(data) {
	return request.put('/mobile/dfm/deviceExamine/item', data);
}

// 票证
const safetyRequest = new RequestBase(config.specialWorkUrl);
export const ticketList = (data) => {
	data.pageNum = 1;
	data.pageSize = 9999;
	return safetyRequest.get('/spw/ticket-exec/his-list/', data);
};

/**
 * 办票
 */
export function bill(data) {
	return request.put('/mobile/dfm/deviceExamine/bill', data);
}

/**
 * 停车方案
 */
export function park(data) {
	return request.put('/mobile/dfm/deviceExamine/park', data);
}

/**
 * 分析
 */
export function analysis(data) {
	return request.put('/mobile/dfm/deviceExamine/analysis', data);
}

/**
 * 执行
 */
export function pursue(data) {
	return request.put('/mobile/dfm/deviceExamine/pursue', data);
}

//备件列表
export function getPart(examineId) {
	return request.get(
		'/mobile/dfm/deviceExamine/getExaminePartsList/' + examineId
	);
}

/**
 * 提验
 */
export function check(data) {
	return request.put('/mobile/dfm/deviceExamine/check', data);
}

/**
 * 验收
 */
export function accept(data) {
	return request.put('/mobile/dfm/deviceExamine/accept', data);
}

/**
 * 检修列表v2
 */
export function queryList({
	pageSize = 10,
	pageNum = 1
} = {}) {
	return request.get(
		`/dfm/deviceExamine/v2/list?pageNum=${pageNum}&pageSize=${pageSize}`
	);
}

/**
 * 检修报备v2
 */
export function addItemV2(data) {
	return request.post('/dfm/deviceExamine/v2/', data);
}

/**
 * 通过id获取详细信息V2
 */
export function queryInfoV2(id) {
	return request.get('/dfm/deviceExamine/v2/' + id);
}

/**
 * 修改检修信息
 */
export function updateItem(data) {
	return request.put('/dfm/deviceExamine/v2/', data);
}

/**
 * 删除检修项目
 */
export function deleteItem(id) {
	return request.delete('/dfm/deviceExamine/v2/' + id);
}

// 检修列表
export function getRepairTaskList({
	pageSize = 10,
	pageNum = 1
} = {}) {
	return request.get(`/mobile/dfm/overhaul/task/list?pageNum=${pageNum}&pageSize=${pageSize}`)
}

// 可选检修设备列表
export function getTaskDevice(data) {
	return request.get('/mobile/dfm/overhaul/task/query/device/list', data)
}

// 删除检修需求
export function deleteTask(taskId) {
	return request.delete(`/mobile/dfm/overhaul/task/delete/${taskId}`)
}

// 创建检修任务
export function addTask(data) {
	return request.post('/mobile/dfm/overhaul/task/create', data)
}

// 查看任务详情
export function getTaskDetail(taskId) {
	return request.get(`/mobile/dfm/overhaul/task/detail/${taskId}`)
}

// 查询可选检修任务
export function getStandardItemList(data) {
	return request.get('/mobile/dfm/overhaul/task/query/standard/item/list', data)
}